<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<blockquote class="layui-elem-quote layui-text">
    Demo
</blockquote>
<!--
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>表单集合演示</legend>
</fieldset>
-->
<div class="layui-container">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">时间设置</label>
            <label class="layui-form-label">任务开始</label>
            <div class="layui-input-inline">
                <input type="text" name="number" id="date1" placeholder="yyyy-MM-dd HH:mm:ss" lay-verify="datetime" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">任务结束</label>
            <div class="layui-input-inline">
                <input type="text" name="date" id="date" lay-verify="datetime" placeholder="yyyy-MM-dd HH:mm:ss" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md10">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">轨道设置</label>
            <label class="layui-form-label">监视星轨道设置</label>
            <div class="layui-input-inline">
                <select name="interest" lay-filter="aihao">
                    <option value="0">写入文件</option>
                    <option value="1" selected="">读取文件</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">目标星轨道设置</label>
            <div class="layui-input-inline">
                <select name="interest" lay-filter="aihao">
                    <option value="0">写入文件</option>
                    <option value="1" selected="">读取文件</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">模式选择</label>
            <div class="layui-input-inline">
                <input type="radio" name="model" value="1" title="GEO目标遍历">
            </div>
            <div class="layui-input-inline">
                <select name="interest" lay-filter="aihao">
                    <option value="0" selected>软件计算</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="radio" name="model" value="1" title="重点GEO目标观测">
            </div>
            <div class="layui-input-inline">
                <select name="interest" lay-filter="aihao">
                    <option value="0" selected>软件计算</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span style="padding-left: 55px"></span></label>
            <div class="layui-input-inline">
                <input type="radio" name="model" value="1" title="LEO目标成像">
            </div>
            <div class="layui-input-inline">
                <select name="interest" lay-filter="aihao">
                    <option value="0" selected>软件计算</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="radio" name="model" value="1" title="LEO目标无线电侦查">
            </div>
            <div class="layui-input-inline">
                <select name="interest" lay-filter="aihao">
                    <option value="0" selected>软件计算</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span style="padding-left: 55px"></span></label>
            <div class="layui-input-inline">
                <input type="radio" name="model" value="1" title="对地数传/测控">
            </div>
            <div class="layui-input-inline">
                <select name="interest" lay-filter="aihao">
                    <option value="0" selected>软件计算</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="radio" name="model" value="1" title="多任务混合规划">
            </div>
            <div class="layui-input-inline">
                <select name="interest" lay-filter="aihao">
                    <option value="0" selected>软件计算</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">文件选择</label>
                <label class="layui-form-label">开工文件</label>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="test1">选择文件</button>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">两行根数文件</label>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="test2">选择文件</button>
                </div>
            </div>
        <div class="layui-inline">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline">
                <input id="kgfile" type="hidden"/>
                <input id="lhgsfile" type="hidden"/>
                <button type="button" class="layui-btn" id="test3">执行</button>
            </div>
        </div>
        </div>
        </div>
        <div class="layui-col-md2">
            <div class="layui-input-inline">
                <textarea rows="15" cols="30"></textarea>
            </div>
        </div>
    </div>
</form>
<table id="pTable" lay-filter="pTableFilter"></table>
<script type="text/html" id="watchBar">
    <a class="layui-table-link" lay-event="file_detail">查看</a>
</script>
</div>
<script src="layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate','upload','jquery','table'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,upload = layui.upload
            ,table = layui.table
            ,$ = layui.jquery
            ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#date1'
            ,type: 'datetime'
        });

        upload.render({
            elem: '#test1'
            ,url: '/fileUpload'
            ,accept: 'file' //普通文件
            ,exts:'IFM|TLE'
            ,done: function(res){
                if(res.resultCode==0){
                    layer.msg('文件上传成功', {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){});
                    $("#kgfile").val(res.filePath);
                }
            }
        });
        var listTableObj = table.render({
            elem: '#pTable'
            ,height: 315
            ,url: '/getFileList' //数据接口
            //,page: true //开启分页
            ,cols: [
                [ //表头
                {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
                ,{field: 'fileName', title: '文件名'}
                ,{field: "oper", title: "查看", width: 200, align:'center',toolbar: '#watchBar',exportable: true}
            ]
            ]
            ,response: {
                statusName: 'resultCode' //数据状态的字段名称，默认：code
                ,statusCode: 0 //成功的状态码，默认：0
                ,msgName: 'resultMsg' //状态信息的字段名称，默认：msg
                ,countName: 'total' //数据总数的字段名称，默认：count
                ,dataName: 'data' //数据列表的字段名称，默认：data
            }
        });

        upload.render({
            elem: '#test2'
            ,url: '/fileUpload'
            ,accept: 'file' //普通文件
            ,exts:'IFM|TLE'
            ,done: function(res){
                if(res.resultCode==0){
                    layer.msg('文件上传成功', {
                        icon: 1,
                        time: 2000
                    });
                    $("#lhgsfile").val(res.filePath);
                }
            }
        });

        $("#test3").on("click", function() {
            if($("#kgfile").val()==''){
                layer.msg('请选择开工文件', {
                    icon: 2,
                    time: 2000
                });
                return;
            }
            if($("#lhgsfile").val()==''){
                layer.msg('请选择两行根数文件', {
                    icon: 2,
                    time: 2000
                });
                return;
            }
            var loadIndex;
            $.ajax({
                type:'post',
                url:'/tleEph',
                beforeSend: function (request) {
                    loadIndex = layer.load();
                },
                success : function(resultData) {
                    if (resultData.resultCode == 0) {
                        setTimeout(function(){
                            layer.close(loadIndex);
                            listTableObj.reload();
                            $.ajax({
                                type:'post',
                                url:'/dealFile',
                                success : function(resultData) {},
                                error : function() {}
                            });
                            }, 3000);
                    }
                },
                error : function() {
                    layer.close(loadIndex);
                    layer.msg("系统异常！", {
                        icon : 0,
                        time : 2000
                    });
                }
            });

        });

        // 监听工具条
        table.on("tool(pTableFilter)", function(obj){
            var data = obj.data;
            if(obj.event==="file_detail"){
                layer.open({
                    type:2,
                    title: "文件内容",
                    area: ["1000px", "640px"],
                    content: "/toFileDetail?fileName="+data.fileName,
                    btnAlign: 'c',
                    anim: 1
                })
            }
        });

    });
</script>
</body>
</html>
